package cn.codesugar.advance

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import cn.codesugar.advance.model.Animal
import cn.codesugar.advance.model.Fruit
import cn.codesugar.advance.model.Person
import cn.codesugar.advance.tools.showToast
import cn.codesugar.advance.utils.*

class SecondActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_second)
        intent.getStringExtra("string_data")?.logInfo()
        intent.getIntExtra("int_data", 0).toString().logAssert()
        (intent.getSerializableExtra("person_data") as Person).toString().logAssert()
        intent.getParcelableExtra<Fruit>("fruit_data").toString().logAssert()
        intent.getParcelableExtra<Animal>("animal_data").toString().showToast()

        LogUtil.setLevel(LogLevel.INFO)
        LogUtil.i("SecondActivity", "Level test Info")
        "Level test Info".logInfo()

        LogUtil.e("SecondActivity", "Level test error")
        "Level test error".logError()

        LogUtil.a("SecondActivity", "Level test assert")
        "Level test assert".logAssert()

        (1 and 2).toString().logInfo() // 0001 0010
        (1 or 2).toString().logInfo()
        (1 xor 3).toString().logInfo() // 0001 0011
    }
}